<?php

	eb_include_class("EbTableSQLModel");
	eb_include_module_file("Core/FilterTable");

	class FilterModel extends EbTableSQLModel
	{
		public function __construct()
		{
			parent::init(new FilterTable());
		}
		
		public function create()
		{
			if (parent::create())
			{
				$this->insert(array("module" => "Core","file" => "Core"));
			}
		}
		
		public function selectPreparedFilters()
		{
			$list = parent::select();
			$listInstances = array();
						
			foreach ($list AS $item)
			{
				$buffer = eb_module_file_new_instance($item->module,$item->file,MODULE_FILE_FILTER);
				
				$buffer->data = eb_parse_parameters_string($item->data);
				
				$listInstances []= $buffer;
			}
			
			return $listInstances;
		}
	}